<?php 
define("ROOTDIR", substr_replace(__FILE__,'',-(strlen(basename(__FILE__))+1)));
define("ROOTURL",substr($_SERVER['PHP_SELF'],0,strlen(basename(__FILE__))+1 ));
	
?>

test demo